import request from '@/utils/axios/axios-service.ts'

/**
 * 用户相关接口
 */
export const userList = (params: any) => request.get('/user/list', {params: params});
export const userInfo = (id: number) => request.get('/user/info/' + id);
export const userSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/user/create' : '/user/update', params);
export const userSwitchStatus = (params: any) => request.post('/user/switch_status', params);
export const modifyUserParent = (params: any) => request.post('/user/modify_parent', params);
export const modifyUserLevel = (params: any) => request.post('/user/modify_user_level', params);
export const modifyPrivateLevel = (params: any) => request.post('/user/modify_private_level', params);
export const modifyUserSoftwareCount = (params: any) => request.post('/user/modify_software_count', params);

/**
 * 用户团队数据接口
 */
export const userPyramidList = (params: any) => request.get('/user/pyramid/list', {params: params});
export const userPyramidInfo = (id: number) => request.get('/user/pyramid/info/' + id);
export const userTeamTreeList = (params: any) => request.get('/user/pyramid/treeList', {params: params});
export const calculateTeamInfo = (params: any) => request.post('/user/pyramid/calculate_team_info', params);
export const batchCalculateTeamInfo = (params: any) => request.post('/user/pyramid/batch_calculate_team_info', params);
export const contributionReleaseCheck = () => request.post('/user/pyramid/contribution_release_check');

/**
 * 实名认证接口
 */
export const userCertifyList = (params: any) => request.get('/user/certify/list', {params: params})
export const userCertifyInfo = (id: number) => request.get('/user/certify/info/' + id)
export const userCertifyInfoByUserId = (userId: number) => request.get('/user/certify/infoByUser/' + userId)
export const userCertifyCreateOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/user/certify/create' : '/user/certify/update', params)

/**
 * 用户登录日志接口
 */
export const userLoginLogList = (params: any) => request.get('/user/login_log/list', {params: params});
export const userPyramidModifyLogList = (params: any) => request.get('/user/pyramid_modify_log/list', {params: params})

/**
 * 设备绑定接口
 */
export const deviceBindConfigList = (params: any) => request.get('/device/bind_config/list', {params: params})
export const deviceBindConfigUpdate = (params: any) => request.post('/device/bind_config/update', params)

export const deviceBindRecord = (params: any) => request.get('/device/bind_record/list', {params: params})
export const deviceBindRecordUnbind = (id: number) => request.post('/device/bind_record/unbind/' + id)

export const deviceAbnormalRecord = (params: any) => request.get('/device/abnormal/list', {params: params})

export type UserInfoData = {
  id: number;
  uid: string;
  account: string;
  password: string;
  pay_password: string;
  nickname: string;
  avatar_url: string;
  invite_code: string;
  register_ip: string;
  register_device_no: string;
  login_status: number;
  forbid_login_note: string;
  last_login_ip: string;
  last_login_time: string;
  special_flag: number;
  account_flag: number;
  parent_id: number;
  parent_account: string;
  parent_nickname: string;
  depth: string;
  tier_level: number;
  user_level: number;
  vip_level: number;
  integral: number;
  merchant_jf: number;
  balance: number;
  subsidy_xs: number;
  subsidy_xx: number;
  bonus_zj: number;
  bonus_hhr: number;
  consume_total: number;
  bonus_extra: number;
  balance_xfj: number;
  contribution_value: number;
  contribution_total: number;
  software_count: number;
  software_trans: number;
  software_used: number;
  private_level: number;
  private_count: number;
  private_first_time: number;
  location: string;
  depth_user_ids: number[];
}

export type UserCertifyData = {
  id: number;
  user_id: number;
  name: string;
  identity_card_no: string;
  front_image_url: string;
  back_image_url: string;
  status: number;
  audit_time: string;
  audit_reason: string;
}

// 默认数据设置
export const defUserInfoData: UserInfoData = <UserInfoData>{};
export const defUserCertifyData: UserCertifyData = <UserCertifyData>{};
